#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;



int main() {
    int n, t;
    cin >> n;
    vector<int>arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    vector<int>dp(n);
    dp[0] = 0;
    int _max = arr[0];
    for (int i = 1; i < n; i++) {
        if (dp[i - 1] >= arr[i]) {
            dp[i] = dp[i - 1];
        }
        else {
            dp[i] = min(_max, arr[i]);
        }
        _max = max(_max, arr[i]);
    }

    cin >> t;
    while (t--) {
        int k;
        cin >> k;
        cout << dp[k - 1] << endl;
    }
    return 0;
}